package com.ak.game.mapper;

import com.ak.game.entity.PnGameMineRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface PnGameMineRecordMapper extends BaseMapper<PnGameMineRecord> {

    @Select("SELECT gr.multiple\n" +
            "FROM pn_game_mine_record gr\n" +
            "JOIN (\n" +
            "    SELECT playSession_id, MAX(start_time) as last_time\n" +
            "    FROM pn_game_mine_record\n" +
            "    GROUP BY playSession_id\n" +
            ") last_times ON gr.playSession_id = last_times.playSession_id\n" +
            "                    AND gr.start_time = last_times.last_time\n" +
            "\t\t\t\t\t\t\t\t\t\tORDER BY start_time desc LIMIT 8")
    List<BigDecimal> selectLastGameMineRecords();
}
